
import allure
#导入该业务有关的页面类
from page.page_ui1 import PageUI1
from page.page_ui2 import PageUI2
from page.page_ui3 import PageUI3


#业务类
class ServiceLogin(object):
    def __init__(self,driver,base_url):
        self.driver=driver
        self.base_url=base_url
        #初始化该业务有关的页面对象
        self.ui1=PageUI1(self.driver,self.base_url)
        self.ui2 = PageUI2(self.driver, self.base_url)
        self.ui3 = PageUI3(self.driver, self.base_url)

    def service_login_001(self,d):
       allure.attach("","步骤1：打开首页")
       self.ui1.openUrl()
       allure.attach("", "步骤2：点击“首页”上的“登录”按钮")
       self.ui1.click_login()
       allure.attach("", f"步骤3：输入账号：{d['zanhao']}")
       self.ui2.inputZanhao(d["zanhao"])
       allure.attach("",f"步骤4：输入密码:{d['pwd']}")
       self.ui2.inputPwd(d["pwd"])
       allure.attach("", "步骤5：点击“登录页面”的登录按钮")
       self.ui2.clickLogin()

       imgName=self.ui3.savePng3("登录",d["key"]) #"登录_K001_20240401033701"
       allure.attach(open(f'./screen/{imgName}.png', 'rb').read(), "步骤6:本次截图", allure.attachment_type.PNG)
       siji=self.ui3.getNicen()
       return d["yuqi"] in siji


    def service_login_002(self,d):
       self.ui1.openUrl()
       self.ui1.click_login()
       self.ui2.inputZanhao(d["zanhao"])
       self.ui2.inputPwd(d["pwd"])
       self.ui2.clickLogin()

       siji=self.ui2.getErrorTip()
       return d["yuqi"] in siji


    def service_login_003(self,d):
       self.ui1.openUrl()
       self.ui1.click_login()
       self.ui2.inputZanhao(d["zanhao"])
       self.ui2.inputPwd(d["pwd"])
       self.ui2.clickLogin()

       siji=self.ui2.getPwdClass()
       return d["yuqi"] in siji


